package com.nineclock.doc.controller;


import com.nineclock.common.entity.PageResult;
import com.nineclock.common.entity.Result;
import com.nineclock.doc.dto.DocFileDto;
import com.nineclock.doc.dto.DocFileHistoryDto;
import com.nineclock.doc.dto.DocFolderDto;
import com.nineclock.doc.service.DocFileService;
import com.nineclock.doc.service.DocHistoryService;
import com.nineclock.doc.service.DocFolderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping
public class DocController  {

     @Autowired
     private DocFolderService docFolderService;

     @Autowired
     private DocHistoryService docFileHistoryService;

     @Autowired
     private DocFileService docFileService;


    @PostMapping("/insertFolder")
    public Result insertFolder(@RequestBody DocFolderDto docFolderDto) {

        docFolderService.insertFolder(docFolderDto);

        return Result.success();
    }


    @GetMapping("/history/{fileId}")
    public Result<List<DocFileHistoryDto>> seeDocEditHistory(@PathVariable("fileId") Long fileId) {

        List<DocFileHistoryDto> docFileHistoryDtos =  docFileHistoryService.seeDocEditHistory(fileId);

        return Result.success(docFileHistoryDtos);
    }
}
